package org.agony2d.view.supportClasses 
{
	import org.agony2d.debug.Logger;
	import org.agony2d.view.Button;
	import org.agony2d.notify.AEvent;

	import org.agony2d.core.agony_internal
	use namespace agony_internal;
	
	
public class AbstractStepRange extends AbstractRange 
{
	
	public function AbstractStepRange( v:Number = 0, min:Number = 0, max:Number = 100, backRef:* = null, forwardRef:* = null )
	{
		super();
		
		if (backRef)
		{
			m_back = new Button(backRef)
			this.addElement(m_back)
			m_back.addEventListener(AEvent.PRESS, ____onStepChange)
		}
		
		if (forwardRef)
		{
			m_forward = new Button(forwardRef)
			this.addElement(m_forward)
			m_forward.addEventListener(AEvent.PRESS, ____onStepChange)
		}
		
		this.autoAdjustPosition()
		m_range.binding(____onRangeChange)
	}
	
	
	
	final public function get stepSize() : Number
	{
		return m_stepSize
	}
	
	final public function set stepSize( v:Number ) : void
	{
		if (v <= 0)
		{
			Logger.reportError(this, 'set stepSize', 'stepSize不可小于或等于0.');
		}
		m_stepSize = v
	}
	
	
	
	final public function changeValueByStep( increased:Boolean ) : void
	{
		if (increased)
		{
			//this.value += m_stepSize
		}
		
		else
		{
			//this.value -= m_stepSize
		}
	}
	
	
	
	protected function ____onStepChange( e:AEvent ) : void
	{
		if (e.target == m_back)
		{
			this.changeValueByStep(false)
		}
		
		else if (e.target == m_forward)
		{
			this.changeValueByStep(true)
		}
	}
	
	
	protected function autoAdjustPosition() : void
	{
	}
	
	
	override agony_internal function dispose() : void
	{
		super.dispose()
		m_back = m_forward = null
	}
	
	
	
	protected var m_back:Button
	
	protected var m_forward:Button
	
	protected var m_stepSize:Number = 1
	
}

}